﻿using IotDeviceToolHepler.Utils;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Management;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace GatewayClient.Common
{
    public static class CommonMachineInfo
    {
        static string deviceId = "";
        /// <summary>
        /// 获取设备id
        /// </summary>
        /// <returns></returns>
        public static string getMachineId()
        {
            //return "32c050000c0048080145c905308a1f8e";
            if (!string.IsNullOrEmpty(deviceId))
            {
                return deviceId;
            }

            //树梅派的方法 Raspberry
            try
            {
                deviceId = new UtilsRaspberryPiMachine().getRaspberryPiDeviceId();
                if (!string.IsNullOrWhiteSpace(deviceId))
                {
                    return deviceId;
                }
            }
            catch (Exception ex)
            {
                // Console.WriteLine("树梅派 设备标识读取失败" + ex);
            }

            // 香橙派系统ubuntu 的方法
            try
            {

                deviceId = new UtilsOrangePiMachine().getOrangePiDeviceId();
                if (!string.IsNullOrWhiteSpace(deviceId))
                {
                    return deviceId;
                }
            }
            catch (Exception ex)
            {
                // Console.WriteLine(" 香橙派 设备标识读取失败" + ex);
            }

            //if (string.IsNullOrWhiteSpace(deviceId))
            //{
            //    //如果没有，就读取设备code
            //    deviceId = getGateWayMachineCode();
            //    if (!string.IsNullOrWhiteSpace(deviceId))
            //    {
            //        return deviceId;
            //    }
            //}
            return "empty";
        }
    }
}

